﻿using Mathmall.Administration.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mathmall.Administration.Data
{
    public class SkuImagesEntityTypeConfiguration : IEntityTypeConfiguration<SkuImage>
    {
        public void Configure(EntityTypeBuilder<SkuImage> builder)
        {
            // 不使用output子句
            builder.ToTable(table => table.UseSqlOutputClause(false));

            builder
                .ToTable(nameof(SkuImage))
                .ToTable(tableBuilder => tableBuilder.HasComment("sku图片"));

            builder
                .HasKey(skuImage => skuImage.SkuImageID)
                .HasName("SkuImageID");

            builder
                .Property(skuImage => skuImage.SkuID)
                .HasColumnName("SkuID")
                .HasColumnType("int")
                .HasComment("skuid")
                .IsRequired(false);

            builder
                .Property(skuImage => skuImage.ImageUrl)
                .HasColumnName("ImageUrl")
                .HasColumnType("varchar(255)")
                .HasComment("图片地址")
                .IsRequired(false);

            builder
                .Property(skuImage => skuImage.ImageSort)
                .HasColumnName("ImageSort")
                .HasColumnType("int")
                .HasComment("排序")
                .IsRequired(false);

            builder
                .Property(skuImage => skuImage.DefaultImg)
                .HasColumnName("DefaultImg")
                .HasColumnType("int")
                .HasComment("默认图[0 - 不是默认图，1 - 是默认图]")
                .IsRequired(false);

            builder
                .Property(skuImage => skuImage.CreateTime)
                .HasColumnName("CreateTime")
                .HasColumnType("datetime")
                .HasComment("创建时间")
                .IsRequired(false);

            builder
                .Property(skuImage => skuImage.LastUpdateTime)
                .HasColumnName("LastUpdateTime")
                .HasColumnType("datetime")
                .HasComment("最后更新时间")
                .IsRequired(false);
        }
    }
}
